<template>
<div>
    <input type="text" v-model="val">
    <button @click="handleadd">提交</button>
</div>
</template>
<script setup>
import {ref,defineEmits} from "vue"

let val=ref("")
let emit=defineEmits(['add'])
//添加数据
let handleadd=()=>{
    if(val.value){
        emit('add',val.value)
        val.value=""
    }else{
        return
    }
}
</script>